#include "can_motor_class.h"
#include "bsp_can.h"
#include "can_motor_user.h"
#include <cmsis_os.h>
#include <cmsis_os2.h>
#include "bsp_uart.h"
#include "string.h"
#include "test.h"

extern "C" void testTask(void *argument);
osThreadId_t	testTaskHandle;		    
osThreadAttr_t testTask_attributes;


__attribute__((used)) uint8_t arr[25];
__attribute__((used)) uint32_t cnt = 0;

__attribute__((used)) uint8_t max_size = 0;


extern "C" void test_task_init()
{

    testTask_attributes.name = "Can1ContrlTask";
    testTask_attributes.stack_size = 128 * 4;
    testTask_attributes.priority = (osPriority_t) osPriorityBelowNormal7;    //???belownormal17(?normal???)
    testTaskHandle = osThreadNew(testTask, NULL, &testTask_attributes);
}

extern "C" void testTask(void *argument)
{
	
		extern Can_motor   m_0x201_can1;
		extern Uart uart8;
		osDelay(2);	
		uart8.rx_mode_config(Uart::uart_e::DMA_IT_HEADED,24,0x55,0x91);

		osDelay(200);	
		for(;;)
		{
			uart8.check_new_data(1);	//等待新数据的到来
			
			uint8_t new_data_len = uart8.acquire_data_length();
			max_size = (max_size >= new_data_len)? max_size : new_data_len;
			
			uart8.acquire_data(arr,uart8.acquire_data_length());	//提取数据
			osDelay(1);
		}
}